home *** CD-ROM | disk | FTP | other *** search
- //-----------------------------------------------------------------------
- //
- // SOLUTION: Inventor Barcelona Lab #1
- //
- // This program illustrates a simple Inventor program which reads
- // in an Inventor file and views it with the `Walkthrough viewer'.
- //
- // EXERCISE::
- // Change the input file to be another file: /usr/share/data/models/*
- //
- // Change the Viewer to be a different viewer:
- // SoExaminerViewer
- // SoFlyViewer
- // SoPlaneViewer
- //
- // Type: make walk1
- //
- //-----------------------------------------------------------------------
-
- #include <stdio.h>
- #include <Inventor/SoDB.h>
- #include <Inventor/nodes/SoSeparator.h>
- #include <Inventor/Xt/SoXt.h>
- #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
-
-
- main(int argc, char **argv)
- {
- // Initialize Inventor
- Widget myWindow = SoXt::init( argv[0] );
- if ( myWindow == NULL ) exit(1);
-
- // Make a viewer part of the window
- SoXtExaminerViewer *viewer = new SoXtExaminerViewer(myWindow);
-
- // Read the object from a file
- SoInput myInput;
- if ( !myInput.openFile("./temple.iv") ) return(1);
- SoSeparator *scene = SoDB::readAll( &myInput );
- if ( scene == NULL ) {
- printf( "Error: temple.iv file read failed!\n" );
- exit(1);
- }
- scene->ref();
-
- // Viewer setup
- viewer->setSceneGraph( scene );
- viewer->setTitle( "Examiner Viewer Program" );
- viewer->show();
- SoXt::show( myWindow );
-
- SoXt::mainLoop();
- }
-